﻿#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QThread>
#include <QTimer>
#include <QDateTime>
#include <QFileDialog>
#include <QPixmap>
#include <QFile>
#include "serial.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
    void InitUI();
    void Refresh_ComList();
    void EnableSelection();
    void DisableSelection();
    Serial * objSerial;//实例化一个串口类Serial的实例objSerial
    QTimer * sendTimer;
    QTimer * findComTimer;
    qint32 ReciveCount = 0;
    qint32 SendCount = 0;
private slots:
    void on_SerialOpen_clicked();   //打开串口

    void on_SerialClose_clicked();  //关闭串口

    void on_ClearRecive_clicked();  //清空接收区

    void on_SnedData_clicked();

    void showRecive(const QByteArray& recive);

    void on_SendClear_clicked();

    void on_OpenFile_clicked();

    void on_LoopSend_clicked();

    void on_SaveData_clicked();
    void on_ClearSend_clicked();

signals:
    void openSerial(QString PortName,qint32 BaudRate,qint8 DataBits,qint8 StopBits,qint8 Parity,qint8 FlowControl);
    void closeSerial();
    void sendData(const QByteArray data);
private:
    Ui::Widget *ui;
    QThread* dvThread;
};
#endif // WIDGET_H
